package com.qf.admin.service.impl;


import com.qf.admin.domain.Address;
import com.qf.admin.domain.Orders;
import com.qf.admin.mapper.AddressMapper;
import com.qf.admin.service.IAddressService;
import com.qf.commons.TableData;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements IAddressService {

    private AddressMapper addressMapper;

    public AddressServiceImpl(AddressMapper addressMapper) {
        this.addressMapper = addressMapper;
    }

    @Override
    public List<Address> getAddressByUserId(Integer userId) {
        return addressMapper.getAddressByUserId(userId);
    }

    /**
     * @param userId
     * @param addressId  被设置为收货地址的id123
     */
    @Override
    public void changeTakeDeliveryAddress(Integer userId, Integer addressId) {
        addressMapper.changeTakeDeliveryAddressu(userId);
        addressMapper.changeTakeDeliveryAddressa(addressId);
    }

    @Override
    public void addAddress(Integer userId, String addressName, String phone, String detail, Integer state) {
        addressMapper.addAddress(userId, addressName, phone, detail, state);
    }

    @Override
    public void updateAddress(Integer userId, String addressName, String phone, String detail, Integer state, Integer addressId) {
        addressMapper.updateAddress(userId, addressName, phone, detail, state, addressId);
    }

    @Override
    public void deleteAddress(Integer userId, Integer addressId) {
        addressMapper.deleteAddress(userId, addressId);
    }

    @Override
    public Address getAddressByAid(Integer aid) {
        return addressMapper.getAddressByAid(aid);
    }

    @Override
    public TableData<Orders> getAddress(Integer limit, Integer offset) {
        TableData<Orders> address = addressMapper.getAddress(limit,offset);
        return address;
    }


    @Override
    public Orders getAddressUser(Integer id) {

        Orders addressUser = addressMapper.getAddressUser(id);
        return addressUser;
    }

    @Override
    public List<Address> getReceiptAddress(Integer id) {

        List<Address> addressList = addressMapper.getReceiptAddress(id);
        return addressList;
    }
}
